package com.example.design.c.state.demo2;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 学生成绩分数系统
 */
@Setter
@Getter
public class ScoreContext {

    /**
     * 构造方法添加初始状态
     */
    public ScoreContext() {
        this.scoreState = new LowState(this);
    }

    /**
     * 分数状态
     */
    private AbstractScoreState scoreState;

    /**
     * 处理实际业务逻辑
     *
     * @param score
     */
    public void add(int score) {
        scoreState.addScore(score);
        System.out.println("当前总成绩为: " + scoreState.getTotalScore());
        System.out.println("当前成绩评价为: " + scoreState.getStateName());
        System.out.println(StrUtil.repeat('=', 50));
    }
}
